/*
 * @(#)ActionProcessingImpl.java
 *
 * @author <a href="denis.gubarev@gmail.com">Denis Gubarev</a>
 */

package com.gshappcore.application.action;

import com.gshappcore.application.action.business.GetProcessing;
import com.gshappcore.application.action.business.GetProcessingImpl;
import com.gshappcore.application.action.mandatory.PostProcessing;
import com.gshappcore.application.action.mandatory.PostProcessingImpl;
import com.gshappcore.model.Model;
import org.springframework.stereotype.Component;


@Component
public class ActionProcessingImpl implements ActionProcessing {

    public Model process(Action action, Model model) {

        ActionType actionType = action.getActionType();
        if (ActionType.MANDATORY.equals(actionType)) {
            GetProcessing getProcessing = new GetProcessingImpl();
            return getProcessing.process(action, model);
        } else if (ActionType.BUSINESS.equals(actionType)) {
            PostProcessing postProcessing = new PostProcessingImpl();
            return postProcessing.process(action, model);
        }
        return null;
    }
}